package com.qf.deviceconsumeropenfeign9003.openfeign;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.qf.deviceconsumeropenfeign9003.interceptors.CookieInterceptor;
import com.qf.deviceconsumeropenfeign9003.openfeign.fallabck.DeviceFeignFallback;
import com.qf.java2106.pojo.Device;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 1、赋值服务提供者控制器中的方法
 * 2、把注解改成@RequestMapping
 * 3、参数使用@RequestParam来修饰，并指定value属性
 * @author q
 * @version V1.0
 * @date 2022/01/18
 **/
/**
 * name : 服务提供者名称
 * path : 统一路径前缀
 * configuration : 加入其他配置，如拦截器
 */
@FeignClient(name = "device-provider",
            path = "/pro/device",
            configuration = CookieInterceptor.class,
            fallback = DeviceFeignFallback.class)
public interface DeviceFeign {

    //=================fegin参数传递开始==========
    //普通参数
    @RequestMapping("/testVar")
    String testVar(@RequestParam(name = "id") Integer id);

    //路径传参
    @RequestMapping("/testUrlVar/{name}")
    String testUrlVar(@PathVariable(value = "name") String name);

    //多个参数
    @RequestMapping("/testManyVar")
    String testManyVar(@RequestParam(name = "id") Integer id, @RequestParam(name = "name") String name);

    //实体参数
    @RequestMapping("/testJson")
    Device testJson(@RequestBody Device device);

    @RequestMapping("/testCookie")
    String testCookie(@RequestBody Device device);

    //=================fegin参数传递结束==========

}
